#ifndef SRC_TEST_CONTROLLER_SSH_H_
#define SRC_TEST_CONTROLLER_SSH_H_

#include <thread>
#include "base/noncopyable.hpp"
#include "libssh/libssh.h"

class SSH : public noncopyable,
  public std::enable_shared_from_this<SSH> {
 public:
  typedef std::shared_ptr<SSH> Ptr;
  SSH();
  virtual ~SSH();

 public:
  bool Initialize(const char *host, int port,
                  const char *username, const char *password);
  void ExecuteShell(const char *commandline);
  bool ExecuteCommand(const char *commandline);
  bool ExecuteCommand(const char *commandline, std::string &result);
  bool Download(const char *remote_path, const char *local_path);
  bool Upload(const char* local_path, const char* remote_path);
  bool Upload(const char* data, size_t data_size,
              const char* filename, const char* remote_path);
  bool IsExist(const char *commandline, const char *find);
  void Uninitialize();

 private:
  ssh_session session_;
  ssh_channel shell_channel_;
};

#endif  // SRC_TEST_CONTROLLER_SSH_H_
